| 
                
               | 
              
                
               | 
              
                @@ -886,67 +886,63 @@ def pai2_home_api(request): 
               | 
            
            
            
              | 
                886
               | 
              
                886
               | 
              
                     num = int(request.POST.get('num', settings.PAI2_HOME_PER_PAGE))
               | 
            
            
            
              | 
                887
               | 
              
                887
               | 
              
                  
               | 
            
            
            
              | 
                888
               | 
              
                888
               | 
              
                     # 执行原生 SQL 语句,获取首页照片列表 
               | 
            
            
            
              | 
                889
               | 
              
                
               | 
              
                -    # cursor = connection.cursor() 
               | 
            
            
            
              | 
                890
               | 
              
                
               | 
              
                -    # cursor.execute(PAI2_HOME_API.format( 
               | 
            
            
            
              | 
                891
               | 
              
                
               | 
              
                -    #     user_id=user_id, 
               | 
            
            
            
              | 
                892
               | 
              
                
               | 
              
                -    #     offset=0, 
               | 
            
            
            
              | 
                893
               | 
              
                
               | 
              
                -    #     rows=settings.PAI2_HOME_MAX_ROWS, 
               | 
            
            
            
              | 
                894
               | 
              
                
               | 
              
                -    # )) 
               | 
            
            
            
              | 
                895
               | 
              
                
               | 
              
                -    # rows = cursor.fetchall() 
               | 
            
            
            
              | 
                896
               | 
              
                
               | 
              
                - 
               | 
            
            
            
              | 
                897
               | 
              
                
               | 
              
                -    # 使用 records 执行原生 SQL 语句,获取首页照片列表 
               | 
            
            
            
              | 
                898
               | 
              
                
               | 
              
                -    rows = db.query(PAI2_HOME_API.format( 
               | 
            
            
            
              | 
                
               | 
              
                889
               | 
              
                +    cursor = connection.cursor() 
               | 
            
            
            
              | 
                
               | 
              
                890
               | 
              
                +    cursor.execute(PAI2_HOME_API.format( 
               | 
            
            
            
              | 
                899
               | 
              
                891
               | 
              
                         user_id=user_id, 
               | 
            
            
            
              | 
                900
               | 
              
                892
               | 
              
                         offset=0, 
               | 
            
            
            
              | 
                901
               | 
              
                893
               | 
              
                         rows=settings.PAI2_HOME_MAX_ROWS, 
               | 
            
            
            
              | 
                902
               | 
              
                
               | 
              
                -    )).all() 
               | 
            
            
            
              | 
                
               | 
              
                894
               | 
              
                +    )) 
               | 
            
            
            
              | 
                
               | 
              
                895
               | 
              
                +    rows = cursor.fetchall() 
               | 
            
            
            
              | 
                
               | 
              
                896
               | 
              
                + 
               | 
            
            
            
              | 
                
               | 
              
                897
               | 
              
                +    # 使用 records 执行原生 SQL 语句,获取首页照片列表 
               | 
            
            
            
              | 
                
               | 
              
                898
               | 
              
                +    # rows = db.query(PAI2_HOME_API.format( 
               | 
            
            
            
              | 
                
               | 
              
                899
               | 
              
                +    #     user_id=user_id, 
               | 
            
            
            
              | 
                
               | 
              
                900
               | 
              
                +    #     offset=0, 
               | 
            
            
            
              | 
                
               | 
              
                901
               | 
              
                +    #     rows=settings.PAI2_HOME_MAX_ROWS, 
               | 
            
            
            
              | 
                
               | 
              
                902
               | 
              
                +    # )).all() 
               | 
            
            
            
              | 
                903
               | 
              
                903
               | 
              
                  
               | 
            
            
            
              | 
                904
               | 
              
                904
               | 
              
                     # 首页照片分页 
               | 
            
            
            
              | 
                905
               | 
              
                905
               | 
              
                     rows, left = pagination(rows, page, num) 
               | 
            
            
            
              | 
                906
               | 
              
                906
               | 
              
                  
               | 
            
            
            
              | 
                907
               | 
              
                907
               | 
              
                     # 首页照片信息 
               | 
            
            
            
              | 
                908
               | 
              
                
               | 
              
                -    # rows = [{
               | 
            
            
            
              | 
                909
               | 
              
                
               | 
              
                -    #     'group_id': row[0], 
               | 
            
            
            
              | 
                910
               | 
              
                
               | 
              
                -    #     'group_name': row[1], 
               | 
            
            
            
              | 
                911
               | 
              
                
               | 
              
                -    #     'group_default_avatar': row[2], 
               | 
            
            
            
              | 
                912
               | 
              
                
               | 
              
                -    #     'group_avatar': row[3], 
               | 
            
            
            
              | 
                913
               | 
              
                
               | 
              
                -    #     'group_from': row[4], 
               | 
            
            
            
              | 
                914
               | 
              
                
               | 
              
                -    #     'photo_id': row[5], 
               | 
            
            
            
              | 
                915
               | 
              
                
               | 
              
                -    #     'photo_url': img_url(row[6]), 
               | 
            
            
            
              | 
                916
               | 
              
                
               | 
              
                -    #     'photo_w': row[7], 
               | 
            
            
            
              | 
                917
               | 
              
                
               | 
              
                -    #     'photo_h': row[8], 
               | 
            
            
            
              | 
                918
               | 
              
                
               | 
              
                -    #     'photo_thumbnail_url': img_url(row[9]), 
               | 
            
            
            
              | 
                919
               | 
              
                
               | 
              
                -    #     'photo_thumbnail_w': row[10], 
               | 
            
            
            
              | 
                920
               | 
              
                
               | 
              
                -    #     'photo_thumbnail_h': row[11], 
               | 
            
            
            
              | 
                921
               | 
              
                
               | 
              
                -    #     'photo_thumbnail2_url': img_url(row[12]), 
               | 
            
            
            
              | 
                922
               | 
              
                
               | 
              
                -    #     'photo_thumbnail2_w': row[13], 
               | 
            
            
            
              | 
                923
               | 
              
                
               | 
              
                -    #     'photo_thumbnail2_h': row[14], 
               | 
            
            
            
              | 
                924
               | 
              
                
               | 
              
                -    #     'photo_share_url': share_url(row[5]),  # Warning: Index of This Line is 5 
               | 
            
            
            
              | 
                925
               | 
              
                
               | 
              
                -    #     'user_id': row[15], 
               | 
            
            
            
              | 
                926
               | 
              
                
               | 
              
                -    #     'nickname': row[16], 
               | 
            
            
            
              | 
                927
               | 
              
                
               | 
              
                -    #     'avatar': row[17], 
               | 
            
            
            
              | 
                928
               | 
              
                
               | 
              
                -    #     'comment_num': row[18], 
               | 
            
            
            
              | 
                929
               | 
              
                
               | 
              
                -    #     'thumbup_num': row[19], 
               | 
            
            
            
              | 
                930
               | 
              
                
               | 
              
                -    #     'photo_from': row[20], 
               | 
            
            
            
              | 
                931
               | 
              
                
               | 
              
                -    #     'created_at': row[21], 
               | 
            
            
            
              | 
                932
               | 
              
                
               | 
              
                -    # } for row in rows] 
               | 
            
            
            
              | 
                933
               | 
              
                
               | 
              
                - 
               | 
            
            
            
              | 
                
               | 
              
                908
               | 
              
                +    rows = [{
               | 
            
            
            
              | 
                
               | 
              
                909
               | 
              
                +        'group_id': row[0], 
               | 
            
            
            
              | 
                
               | 
              
                910
               | 
              
                +        'group_name': row[1], 
               | 
            
            
            
              | 
                
               | 
              
                911
               | 
              
                +        'group_default_avatar': row[2], 
               | 
            
            
            
              | 
                
               | 
              
                912
               | 
              
                +        'group_avatar': row[3], 
               | 
            
            
            
              | 
                
               | 
              
                913
               | 
              
                +        'group_from': row[4], 
               | 
            
            
            
              | 
                
               | 
              
                914
               | 
              
                +        'photo_id': row[5], 
               | 
            
            
            
              | 
                
               | 
              
                915
               | 
              
                +        'photo_url': img_url(row[6]), 
               | 
            
            
            
              | 
                
               | 
              
                916
               | 
              
                +        'photo_w': row[7], 
               | 
            
            
            
              | 
                
               | 
              
                917
               | 
              
                +        'photo_h': row[8], 
               | 
            
            
            
              | 
                
               | 
              
                918
               | 
              
                +        'photo_thumbnail_url': img_url(row[9]), 
               | 
            
            
            
              | 
                
               | 
              
                919
               | 
              
                +        'photo_thumbnail_w': row[10], 
               | 
            
            
            
              | 
                
               | 
              
                920
               | 
              
                +        'photo_thumbnail_h': row[11], 
               | 
            
            
            
              | 
                
               | 
              
                921
               | 
              
                +        'photo_thumbnail2_url': img_url(row[12]), 
               | 
            
            
            
              | 
                
               | 
              
                922
               | 
              
                +        'photo_thumbnail2_w': row[13], 
               | 
            
            
            
              | 
                
               | 
              
                923
               | 
              
                +        'photo_thumbnail2_h': row[14], 
               | 
            
            
            
              | 
                
               | 
              
                924
               | 
              
                +        'photo_share_url': share_url(row[5]),  # Warning: Index of This Line is 5 
               | 
            
            
            
              | 
                
               | 
              
                925
               | 
              
                +        'user_id': row[15], 
               | 
            
            
            
              | 
                
               | 
              
                926
               | 
              
                +        'nickname': row[16], 
               | 
            
            
            
              | 
                
               | 
              
                927
               | 
              
                +        'avatar': row[17], 
               | 
            
            
            
              | 
                
               | 
              
                928
               | 
              
                +        'comment_num': row[18], 
               | 
            
            
            
              | 
                
               | 
              
                929
               | 
              
                +        'thumbup_num': row[19], 
               | 
            
            
            
              | 
                
               | 
              
                930
               | 
              
                +        'photo_from': row[20], 
               | 
            
            
            
              | 
                
               | 
              
                931
               | 
              
                +        'created_at': row[21], 
               | 
            
            
            
              | 
                
               | 
              
                932
               | 
              
                +        'thumbup': get_group_photo_thumbup_flag(row[5], user_id), 
               | 
            
            
            
              | 
                
               | 
              
                933
               | 
              
                +        'porder': get_lensman_order_record(row[5], user_id) if row[20] == GroupPhotoInfo.SESSION_GROUP else {},
               | 
            
            
            
              | 
                
               | 
              
                934
               | 
              
                +    } for row in rows] 
               | 
            
            
            
              | 
                
               | 
              
                935
               | 
              
                + 
               | 
            
            
            
              | 
                
               | 
              
                936
               | 
              
                +    # rows = [dict(row) for row in rows] 
               | 
            
            
            
              | 
                934
               | 
              
                937
               | 
              
                     # [row.update({
               | 
            
            
            
              | 
                
               | 
              
                938
               | 
              
                +    #     'photo_url': img_url(row['photo_path']), 
               | 
            
            
            
              | 
                
               | 
              
                939
               | 
              
                +    #     'photo_thumbnail_url': img_url(row['photo_thumbnail_path']), 
               | 
            
            
            
              | 
                
               | 
              
                940
               | 
              
                +    #     'photo_thumbnail2_url': img_url(row['photo_thumbnail2_path']), 
               | 
            
            
            
              | 
                
               | 
              
                941
               | 
              
                +    #     'photo_share_url': share_url(row['photo_id']), 
               | 
            
            
            
              | 
                935
               | 
              
                942
               | 
              
                     #     'thumbup': get_group_photo_thumbup_flag(row['photo_id'], user_id), 
               | 
            
            
            
              | 
                936
               | 
              
                
               | 
              
                -    #     'porder': get_lensman_order_record(row['photo_id'], user_id) if row['photo_from'] == GroupPhotoInfo.SESSION_GROUP else {}
               | 
            
            
            
              | 
                
               | 
              
                943
               | 
              
                +    #     'porder': get_lensman_order_record(row['photo_id'], user_id) if row['photo_from'] == GroupPhotoInfo.SESSION_GROUP else {},
               | 
            
            
            
              | 
                937
               | 
              
                944
               | 
              
                     # }) for row in rows] 
               | 
            
            
            
              | 
                938
               | 
              
                945
               | 
              
                  
               | 
            
            
            
              | 
                939
               | 
              
                
               | 
              
                -    rows = [dict(row) for row in rows] 
               | 
            
            
            
              | 
                940
               | 
              
                
               | 
              
                -    [row.update({
               | 
            
            
            
              | 
                941
               | 
              
                
               | 
              
                -        'photo_url': img_url(row['photo_path']), 
               | 
            
            
            
              | 
                942
               | 
              
                
               | 
              
                -        'photo_thumbnail_url': img_url(row['photo_thumbnail_path']), 
               | 
            
            
            
              | 
                943
               | 
              
                
               | 
              
                -        'photo_thumbnail2_url': img_url(row['photo_thumbnail2_path']), 
               | 
            
            
            
              | 
                944
               | 
              
                
               | 
              
                -        'photo_share_url': share_url(row['photo_id']), 
               | 
            
            
            
              | 
                945
               | 
              
                
               | 
              
                -        'thumbup': get_group_photo_thumbup_flag(row['photo_id'], user_id), 
               | 
            
            
            
              | 
                946
               | 
              
                
               | 
              
                -        'porder': get_lensman_order_record(row['photo_id'], user_id) if row['photo_from'] == GroupPhotoInfo.SESSION_GROUP else {},
               | 
            
            
            
              | 
                947
               | 
              
                
               | 
              
                -        'created_at': '{}Z'.format(row['created_at']),
               | 
            
            
            
              | 
                948
               | 
              
                
               | 
              
                -    }) for row in rows] 
               | 
            
            
            
              | 
                949
               | 
              
                
               | 
              
                - 
               | 
            
            
            
              | 
                950
               | 
              
                946
               | 
              
                     return JsonResponse({
               | 
            
            
            
              | 
                951
               | 
              
                947
               | 
              
                         'status': 200, 
               | 
            
            
            
              | 
                952
               | 
              
                948
               | 
              
                         'message': u'获取首页列表成功', 
               |